﻿/* 
 * Produzido por:
 *      Daniel Vargas
 *      Danilo Valvezon
 *      Fernanda Osaki
 *      Tiago Ricardo Almeida da Silva
 *      
 * FATEC São Caetano do Sul
 * Jogos NA6
 * */


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace bomberboyonline
{
    class TelaInicial : Microsoft.Xna.Framework.DrawableGameComponent
    {
        private Texture2D textura;
        private Game game;

        public TelaInicial(Game game)
            : base(game)
        {
            this.game = game;
            textura = game.Content.Load<Texture2D>("arquivos\\bomberbanner2");
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            KeyboardState ks = Keyboard.GetState(); // Pega os eventos de teclado
            if (ks.IsKeyDown(Keys.Escape))
            {
                game.Exit(); // se a tecla pressionada é o ESC, finaliza o jogo
            }
            if (ks.IsKeyDown(Keys.F2))
            {
                game.Components.Remove(this);
                game.Components.Add(new TelaJogo(game, 2)); // Cria Jogo
            }
            if (ks.IsKeyDown(Keys.F3))
            {
                game.Components.Remove(this);
                game.Components.Add(new TelaJogo(game, 3)); // Cria Jogo
            }
            if (ks.IsKeyDown(Keys.F4))
            {
                game.Components.Remove(this);
                game.Components.Add(new TelaJogo(game, 4)); // Cria Jogo
            }
            base.Update(gameTime);
        }

        /// <summary>
        /// Allows the game component to draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Draw(GameTime gameTime)
        {
            // Pega o Spritebatch do Services
            SpriteBatch sBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            // Desenha o fundo
            sBatch.Draw(textura, new Rectangle(0, 0, Game.Window.ClientBounds.Width, Game.Window.ClientBounds.Height), Color.White);

            base.Draw(gameTime);
        }

    }
}
